package com.fengdi.book.easy.Array;

public class RemoveDuplicates {
    public int removeDuplicates(int[] nums) {
        if (nums.length == 0) return 0;

        if (nums.length == 1) return 1;

        int length = nums.length;

        for(int i = 1; i < length; ){
            if(nums[i] != nums[i-1]){
                i++;
                continue;
            }

            for(int j = i; j < length; j++){
                nums[j - 1] = nums[j];
            }
            length--;
        }

        return length;
    }
}
